//顺序表

//顺序表的类型定义
template<typename E,int MAXSIZE>
struct SqList
{
    E elem[MAXSIZE];
    int length;
};
//初始化空表
template<typename E,int MAXSIZE>
  void InitList(SqList<E,MAXSIZE>&L)
{
      L.length = 0;
}
//求表长

//在顺序表 L 中第 i 个位置插入元素 e
template<typename E,int MAXSIZE>
void ListInsert(SqList<E,MAXSIZE> &L,int i,E e)
    { 
      if(L.length==MAXSIZE) throw"List if full";
      if(i<1||i>L.length+1)throw"i out of range";
    
      for(int j=L.length-1;j>=i-1;j--)
    
      L.elem[j+1]=L.elem[j];
      L.elem[i-1]=e;
      L.length++;
    }
    //删除顺序表 L 中第 i 个元素，用 e 返回
    template<typename E,int MAXSIZE>
    void ListDelete(SqList<E, MAXSIZE>&L,int i, E&e)
    {
       if(L.length==0) throw"List is empty"; 
       if(i<1||i>L.length) throw"i out range";
    
       e=L.elem[i-1] ;
       for(int j=i; j<L.length; j++) 
      {
        L.elem[j-1] =L.elem[j] ;
      }
         L.length--; 
    }